import logging
import time

import yaml
def read_yaml():
    with open('D:\gao62301a\gaoliumoli\yuekaomoli\Data\yaml.yaml','r',encoding='utf-8') as p:
        return yaml.safe_load(p)

# t=time.strftime("%Y%m%d_%H%M%S",time.localtime())
# def get_logger(name='test_email.py'):
#     logger=logging.getLogger(name)
#     if not logger.handlers:
#         fmt=logging.Formatter('%(asctime)s-%(levelname)s-%(message)s-%(filename)s')
#         # 日志信息
#         file_hd=logging.FileHandler(f'WY_{t}.log',encoding='utf-8')
#         file_hd.setFormatter(fmt)
#         logger.addHandler(file_hd)
#
#         # 控制台信息
#         console_hd=logging.StreamHandler()
#         console_hd.setFormatter(fmt)
#         logger.addHandler(console_hd)
#         # 日志级别
#         logger.setLevel(logging.INFO)
#
#     return logger

t=time.strftime('%Y%m%d_%H%M%S',time.localtime())
def get_logger(name='test_email.py'):
    logger=logging.getLogger(name)
    if not logger.handlers:
        fmt=logging.Formatter('%(asctime)s-%(levelname)s-%(message)s-%(filename)s')
        file_hd=logging.FileHandler(f'WY_{t}.log',encoding='utf-8')
        file_hd.setFormatter(fmt)
        logger.addHandler(file_hd)

        con_hd=logging.StreamHandler()
        con_hd.setFormatter(fmt)
        logger.addHandler(con_hd)

        logger.setLevel(logging.INFO)

    return logger